package com.zjsru.plan2024.oneday;

import java.util.Arrays;

/**
 * 判定字符是否唯一
 * @Author: cookLee
 * @Date: 2024-05-06
 */
public class IsUnique {

    /**
     * 主
     * 输入: s = "leetcode"
     * 输出: false
     * @param args args
     */
    public static void main(String[] args) {
        IsUnique isUnique = new IsUnique();
        String astr = "leetcode";
        System.out.println(isUnique.isUnique(astr));
    }


    /**
     * 是独一无二
     *
     * @param astr astr
     * @return boolean
     */
    public boolean isUnique(String astr) {
        char[] charArray = astr.toCharArray();
        int[] nums = new int[26];
        for (char c : charArray) {
            nums[c - 'a'] ++;
        }
        return Arrays.stream(nums).filter(v -> v > 1).sum() <= 0;
    }
}
